import asyncio
import os.path
import time
from datetime import datetime
#
#


#
# f4=open('/Users/daxiang/Downloads/prod.txt', encoding='utf-8')
# f5=open('/Users/daxiang/Downloads/camera.txt', encoding='utf-8')
# #此时只读取了一行
# pre_prod = f4.readline()
# pre_camera = f5.readline()
# #利用循环全部读出
# i = 1
# while pre_prod and pre_camera:
#     next_line_prod = f4.readline()
#     next_line_camera = f5.readline()
#     next_line_prod = next_line_prod.replace("\n","")
#     next_line_camera = next_line_camera.replace("\n", "")
#     next_line_prod_date = datetime.strptime(next_line_prod, '%Y-%m-%d %H:%M:%S.%f')
#     next_line_camera_date = datetime.strptime(next_line_camera, '%Y-%m-%d %H:%M:%S.%f')
#
#     gap = (next_line_camera_date - next_line_prod_date).seconds
#     print(f"line no: {i} --{next_line_prod}-----{next_line_camera}---- {gap}")
#     pre_prod = next_line_prod
#     pre_camera = next_line_camera
#     i += 1
# f4.close()




#
#
#
#

# def test_with():
#     print("---------111111111---------")
#     with open("/Users/daxiang/Downloads/aa.txt" , "w") as file:
#         for i in range(10):
#             file.write("11111111111111")
#             time.sleep(1)
#
#     print("---------222222222---------")
#
#
# test_with()




# import  gzip
# zip_filename = './aa.1'
# with open('./aa_1.txt','wb') as pw:
#     zf = gzip.open(zip_filename, mode = 'rb')
#     pw.write(zf.read())  # 写文件
#     zf.close()





# async def testWhile():
#     index = 0
#     while True:
#         try:
#             index = index + 1
#             raise Exception(f"------index:{index}")
#         except Exception as e:
#             if index == 5:
#                 return
#             else:
#                 print(f"----------error:{e}")
#
#         await asyncio.sleep(3)
#
# asyncio.run(testWhile())


#
# import asyncio
#
# async def consumer(queue):
#     while True:
#         item = await queue.get()
#         print('Consumed:', item)
#
# async def producer():
#     i = 0
#     while True:
#         await asyncio.sleep(1)  # 模拟生产延迟
#         i+=1
#         print('Produced:', i)
#
# async def main():
#     queue = asyncio.Queue()
#     tasks = [
#         asyncio.create_task(consumer(queue)),
#         asyncio.create_task(producer())
#     ]
#     await asyncio.gather(*tasks)
#
# asyncio.run(main())




# f=open('/Users/daxiang/Downloads/cc.txt', encoding='utf-8')
# #此时只读取了一行
# pre_line = f.readline()
# #利用循环全部读出
# i = 1
# while pre_line:
#     next_line = f.readline()
#
#     pre_line = pre_line.replace("\n","")
#     next_line = next_line.replace("\n","")
#     pre_line_date = datetime.strptime(pre_line, '%Y-%m-%d %H:%M:%S.%f')
#     next_line_date = datetime.strptime(next_line, '%Y-%m-%d %H:%M:%S.%f')
#
#     gap = (next_line_date - pre_line_date)
#     print(f"line no: {i} --{next_line_date}-----{pre_line_date}---- {gap}")
#     pre_line = next_line
#     i += 1
# f.close()
#



#
# file_path = "/app/ai/data/img/L4/1/20240119/227909.jpg"
# spliter = "img"
# idx = file_path.find(spliter)
# sub_str = file_path[idx+len(spliter):len(file_path)]
# print(f"-----sub_str:{sub_str}")
#
#
# all_exist_lines = list()
# f5=open('bbbb.txt', encoding='utf-8')
# #此时只读取了一行
# line_item = f5.readline()
# line_item = line_item.replace("\n","")
# all_exist_lines.append(line_item)
# i = 1
# while line_item :
#     next_line = f5.readline()
#     if line_item not in all_exist_lines  and line_item != "":
#         line_item = line_item.replace("\n", "")
#         all_exist_lines.append(line_item)
#     line_item = next_line
#     i += 1
# f5.close()
# print(f"------all_exist_lines: {all_exist_lines}")
#
#
# lose_exist_signals = list()
# f4=open('aaaa.txt', encoding='utf-8')
# #此时只读取了一行
# line_item1 = f4.readline()
# line_item1 = line_item1.replace("\n","")
# if line_item1 not in all_exist_lines:
#     lose_exist_signals.append(line_item1)
# i = 1
# while line_item1 :
#     next_line = f4.readline()
#     line_item1 = line_item1.replace("\n", "")
#     if line_item1 not in all_exist_lines:
#         lose_exist_signals.append(line_item1)
#     line_item1 = next_line
#     i += 1
# f4.close()
#
# print(f"------lose_exist_signals: {lose_exist_signals}")
#











